package com.hzvictory.hotel_system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hzvictory.hotel_system.common.annotation.Log;
import com.hzvictory.hotel_system.common.core.controller.BaseController;
import com.hzvictory.hotel_system.common.core.domain.AjaxResult;
import com.hzvictory.hotel_system.common.enums.BusinessType;
import com.hzvictory.hotel_system.pojo.entity.ProjectResources;
import com.hzvictory.hotel_system.service.IProjectResourcesService;
import com.hzvictory.hotel_system.common.core.page.TableDataInfo;

/**
 * 项目资源URLController
 *
 * @author hzvictory
 * @date 2025-08-11
 */
@RestController
@RequestMapping("/system/resources")
public class ProjectResourcesController extends BaseController
{
    @Autowired
    private IProjectResourcesService projectResourcesService;

    /**
     * 查询项目资源URL列表
     */
    //@PreAuthorize("@ss.hasPermi('system:resources:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectResources projectResources)
    {
        startPage();
        List<ProjectResources> list = projectResourcesService.selectProjectResourcesList(projectResources);
        return getDataTable(list);
    }

    /**
     * 导出项目资源URL列表
     */
    //@PreAuthorize("@ss.hasPermi('system:resources:export')")
//    @Log(title = "项目资源URL", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ProjectResources projectResources)
//    {
//        List<ProjectResources> list = projectResourcesService.selectProjectResourcesList(projectResources);
//        ExcelUtil<ProjectResources> util = new ExcelUtil<ProjectResources>(ProjectResources.class);
//        util.exportExcel(response, list, "项目资源URL数据");
//    }

    /**
     * 获取项目资源URL详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:resources:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(projectResourcesService.selectProjectResourcesById(id));
    }

    /**
     * 新增项目资源URL
     */
    //@PreAuthorize("@ss.hasPermi('system:resources:add')")
    @Log(title = "项目资源URL", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectResources projectResources)
    {
        return toAjax(projectResourcesService.insertProjectResources(projectResources));
    }

    /**
     * 修改项目资源URL
     */
    //@PreAuthorize("@ss.hasPermi('system:resources:edit')")
    @Log(title = "项目资源URL", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectResources projectResources)
    {
        return toAjax(projectResourcesService.updateProjectResources(projectResources));
    }

    /**
     * 删除项目资源URL
     */
    //@PreAuthorize("@ss.hasPermi('system:resources:remove')")
    @Log(title = "项目资源URL", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectResourcesService.deleteProjectResourcesByIds(ids));
    }
}
